How to loop through linksets

I need to create a document which includes the module(s) that each module links to.  I'm pretty sure the info I need is in the module's linksets, but I'm not sure how to loop through them.  Can anyone tell me how to loop through all linksets in a module?

 

Chris


Christopher Cote - Tue Apr 16 15:29:02 EDT 2019

Re: How to loop through linksets
morast - Wed Apr 17 02:51:54 EDT 2019

Actually linksets are stored in link modules. So if you know or can find the relevant link module(s), you can build what you want based on this snippet:

Module lm = current  // Assuming the current module is a link module
Object lso
for lso in lm do 
{
  print lso."Source" "\n"
  print lso."Target" "\n"
}

Then there is the link module descriptors (link restrictions set in the Linkset tab of Module Properties in a source module), stored in folders:

Folder f = current
LinkModuleDescriptor lmd 
for lmd in f do
{
  print getSourceName(lmd) "\n"
  print getTargetName(lmd) "\n"
}

But the link module descriptors does not necessarily reflect actual linking. I guess actual linking is what you are really interested in:

 

Module m = current
Object o
Link l
Skip skp = createString
string tgtMod

for o in m do 
{
  for l in o -> "*" do
  {
    tgtMod = target l
    put(skp, tgtMod, tgtMod)
  }
}

for tgtMod in skp do print tgtMod "\n"
delete skp

 

Re: How to loop through linksets
Christopher Cote - Wed Apr 17 08:54:20 EDT 2019

morast - Wed Apr 17 02:51:54 EDT 2019

Actually linksets are stored in link modules. So if you know or can find the relevant link module(s), you can build what you want based on this snippet:

Module lm = current  // Assuming the current module is a link module
Object lso
for lso in lm do 
{
  print lso."Source" "\n"
  print lso."Target" "\n"
}

Then there is the link module descriptors (link restrictions set in the Linkset tab of Module Properties in a source module), stored in folders:

Folder f = current
LinkModuleDescriptor lmd 
for lmd in f do
{
  print getSourceName(lmd) "\n"
  print getTargetName(lmd) "\n"
}

But the link module descriptors does not necessarily reflect actual linking. I guess actual linking is what you are really interested in:

 

Module m = current
Object o
Link l
Skip skp = createString
string tgtMod

for o in m do 
{
  for l in o -> "*" do
  {
    tgtMod = target l
    put(skp, tgtMod, tgtMod)
  }
}

for tgtMod in skp do print tgtMod "\n"
delete skp

 

Thank you Henrik.  I don't really need the actual links.  My Excel document is just going to list the other module(s) that each module links to.  For this project, we have 2 different SS modules that a subsystem can link to.  The user just wants to know which one they use, so I think the 2nd snippet will work for me.

 

Chris